{extend name='base' /}
{block name='content'}
<body>
<div class="x-body">
    <form class="layui-form" id="roleData">
        <div class="layui-form-item">
            <label for="role_name" class="layui-form-label">
                <span class="x-red">*</span>角色名字
            </label>
            <div class="layui-input-inline">
                <input type="text" id="role_name" name="role_name" required=""
                       autocomplete="off" value="" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>权限组的名称
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label  class="layui-form-label">
                描述
            </label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容"  name="describe" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label  class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" type="button"  id="roleAdd">
                增加
            </button>
        </div>
    </form>
</div>
<script>
$('#roleAdd').click(function () {
    $.ajax({
        url:"{:url('role/roleadd')}",
        type:'post',
        dataType:"JSON",
        data:$('#roleData').serialize(),
        success:function (res) {
            if (res.code==1){
                layer.msg(res.message,{icon:6});
                setTimeout(function () {
                    x_admin_close();
                    window.parent.location.reload();
                },1000)
            } else{
                layer.msg(res.message,{icon:2,time:1000})
            }
        },
        error:function () {
            layer.msg('出错了，请稍后再试!!',{icon:5,time:1000})
        }
    })
})
</script>

</body>
{/block}